package com.bizzan.bitrade.listenConfig;

import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NacosConfig {

    @Bean
    @ConditionalOnMissingBean  // 如果容器中已经存在该Bean，则不创建
    public NamingService namingService(NacosDiscoveryProperties nacosDiscoveryProperties) throws Exception {
        System.out.println("创建 NamingService Bean...");
        return nacosDiscoveryProperties.namingServiceInstance();
    }
}